import javax.servlet.http.*;
import java.sql.*;
import java.io.*;

public class CollegeStudentSearch extends HttpServlet
{

String student_name;
             String student_id="";
             String college_code="";         
             String course="";  

             String ssc="";
             String ssc_year="";
             String inter="";         
             String inter_year="";     
             String graduation="";
             String graduation_year="";
             String pg="";         
             String pg_year=""; 
             String mobile="";
             String email="";
            
  
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException
  {

    
 
        String student_name=request.getParameter("student");
        response.setContentType("text/html");
         PrintWriter out=response.getWriter();

          try
       {
        Class.forName("oracle.jdbc.driver.OracleDriver");

         Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","pac","mca"); 

         Statement stmt=con.createStatement();
   
        ResultSet rs2=stmt.executeQuery("SELECT student_id,student_name,course from student_register WHERE student_name='"+student_name+"'");

        if(rs2.next())
        {
            student_name = rs2.getString("student_name");
            student_id = rs2.getString("student_id");
            //college_code = rs2.getString(3);         
            course = rs2.getString("course");  

      }
            
          ResultSet rs3=stmt.executeQuery("SELECT *FROM student_marks WHERE student_id='"+student_id+"'");

        if(rs3.next())
        {
            ssc = rs3.getString(1);
            ssc_year = rs3.getString(2);
            inter = rs3.getString(3);         
            inter_year = rs3.getString(4);     
            graduation = rs3.getString(5);
            graduation_year = rs3.getString(6);
            pg = rs3.getString(7);         
            pg_year = rs3.getString(8); 
                             
        }
 ResultSet rs=stmt.executeQuery("SELECT *FROM student_details WHERE student_id='"+student_id+"'");

        while(rs.next())
        {
            mobile=rs.getString("student_mobile");
            email=rs.getString("student_email");
           
        }


out.println("<html><body bgcolor='gray'");
out.println("<br><h1> <font color=\"white\"> "+student_name+" </font> </h1> ");
     out.println("<br> <br> <br> ");

     out.println("<table cellspacing='3'>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> Id  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+student_id+" </font> </b>");
        out.println("</tr>");

       
        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> Course  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+course+" </font> </b>");
        out.println("</tr>");   
     
        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> SSC Marks Percentage </font>  </b>");
              out.println("<td> <b> <font color=\"white\"> :"+ssc+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> Year of Passing  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+ssc_year+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\">Intermediate Marks Percentage </font>  </b>");
              out.println("<td> <b> <font color=\"white\"> :"+inter+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\">Year of Passing  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+inter_year+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\">Degree Marks Percentage  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+graduation+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\">Year of Passing </font>  </b>");
              out.println("<td> <b> <font color=\"white\"> :"+graduation_year+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> PG Marks Percentage </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+pg+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> Year of Passing  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+pg_year+" </font> </b>");
        out.println("</tr>");

     out.println(" </table> ");
      
     out.println("</body>");

     out.println("</html>");   
         }
 
     

    catch(Exception e)
       {
        // response.sendError(505,e.getMessage());
         e.printStackTrace();
       }    

  }

}  

 